<template>
    <div>
        <div class="mui-numbox"  data-numbox-min="1" >
            <button class="mui-btn mui-numbox-btn-minus" type="button">-</button>
            <input class="mui-numbox-input" type="number" @change='buyNumChange' ref='NumChange'>
            <button class="mui-btn mui-numbox-btn-plus" type="button">+</button>
            
        </div>
    </div>
</template>


<script>
import mui from '../../lib/mui/js/mui.min'
export default {
     mounted(){
        mui('.mui-numbox').numbox()
    },
    methods:{
        buyNumChange(){
            // console.log(this.$refs.NumChange.value)
            this.$emit('getBuyNum',parseInt(this.$refs.NumChange.value))
        }
    },
    props:['max'], //这里一定要用max，他是和下面setOption的max是有关联的，换成其他变量名的不行
    watch:{
        max:function(newVal){
            mui('.mui-numbox').numbox().setOption("max",newVal)//文档规定了要用min,step,max！！！
        }
    }
}
</script>